package servlets;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import database.DatabaseOperations;
import database.IDatabaseOperations;

public class AddJob extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private IDatabaseOperations databaseOperations;
	
	/** Process the HTTP Get request */
	public void doPost(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {

		databaseOperations = new DatabaseOperations();
		try {
			int orderId = Integer.parseInt(req.getParameter("orderId"));
			String expName = req.getParameter("expName");
			String destName = req.getParameter("destName");
			String expAddress = req.getParameter("expAddress");
			String destAddress = req.getParameter("destAddress");
			String transporterName = req.getParameter("transporterName");
			
			databaseOperations.addJob(orderId, expName, expAddress, destName, destAddress, transporterName);
			
		} finally {
			databaseOperations.closeConnection();
		}
		
		
	}
}
